/**
 * 2017年11月22日
 */
package com.alibaba.study.io;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;

/**
 * @author Alex
 *
 */
class Me implements Serializable{
	String value = "abcdef";
}
public class IODemo {
	public static void main(String[] args) throws IOException, ClassNotFoundException {
		ByteArrayOutputStream baos = new ByteArrayOutputStream(1000);
		Me m = new Me();
		//FileOutputStream fos = new FileOutputStream(new File(""));

		
		ObjectOutputStream oos = new ObjectOutputStream(baos);
		oos.writeObject(m);
		
		System.out.println(Arrays.toString(baos.toByteArray()));
		System.out.println(new String(baos.toByteArray()));
		ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
		Me m1 = (Me)ois.readObject();
		System.out.println(m1 == m);
		System.out.println(m.value);
	}
}
